package com.zlc.workflow.test;

import com.zlc.common.util.JsonHelper;
import com.zlc.workflow.WorkflowApplication;
import com.zlc.workflow.core.process.cmd.ParseJsonToXmlCmd;
import com.zlc.workflow.core.process.cmd.ParseXmlToJsonCmd;
import com.zlc.workflow.core.process.model.FlowProcess;
import com.zlc.workflow.flow.errorcontext.WindLocalError;
import com.zlc.workflow.utils.StreamHelper;

import java.io.InputStream;
import java.nio.charset.StandardCharsets;

public class ProcessParseTest1 {


    public static void main(String[] args) {
        try {
            InputStream stream = WorkflowApplication.class.getClassLoader().getResourceAsStream("process/Context.xml");
            byte[] aByte = StreamHelper.getByte(stream);
            String s = new String(aByte, StandardCharsets.UTF_8);
            FlowProcess execute = new ParseXmlToJsonCmd(s).execute();
            String s1 = JsonHelper.toJson(execute);
            String xml = new ParseJsonToXmlCmd(execute).execute();
            System.out.println();
            System.out.println();
        }catch (Exception e){
            String errorMsg = WindLocalError.get().errorMsg();
            System.out.println(errorMsg);
        }
    }
}
